/*
 * Copyright 2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.dopdf.document.hash.strategy;

import org.dopdf.document.read.DocumentReader;

/**
 * The interface that represents various fetching strategy that are currently available for fetching the pdf.  Users can
 * choose to provide thier own implementation of the strategy.  Currently there are two inbuild strategies
 * {@link LRUBasedDocumentHashingStrategy} and
 * {@link SessionBasedDocumentHashingStrategy}
 *
 * @author Deep Shah
 */
public interface DocumentHashingStrategy {

    /**
     * Generates a unique hash for the given document.
     *
     *
     * @param documentReader the documentReader for which we need to generate the hash.
     * @return String value representing a unique hash for the passed in document.
     */
    String hash(final DocumentReader documentReader);

    /**
     * Returns the document matching the given hash key.  If the value is not found then null is returned.
     * @param key the key for which we have to find the document.
     * @return the byte array representing the document against the key.
     */
    DocumentReader unHash(final String key);
}
